//
//  EnglishConstants.swift
//  Hyphenate-Demo-Swift
//
//  Created by JennyShi on 2018/4/30.
//  Copyright © 2018年 杜洁鹏. All rights reserved.
//

import UIKit
import os.log

class ChnStatic: NSObject, NSCoding {

    static let enWords : [String : String] = [
        "Calendar" : "Calendar"
        ,"Back" : "Back"
        ,"Public" : "Public"
        ,"public" : "public"
        ,"Personal" : "Personal"
        ,"personal" : "personal"
        ,"Private" : "Private"
        ,"private" : "private"
        ,"OK" : "OK"
        ,"Match" : "Match"
        ,"Free" : "Free"
        ,"free" : "free"
        ,"No free time all the day" : "No free time all the day"
        ,"not going" : "not going"
        ,"going" : "going"
        ,"unread" : "unread"
        ,"undetermined" : "undetermined"
        ,"unknown" : "unknown"
        ,"get data failed" : "get data failed"
        ,"to" : "to"
        ,"Invite" : "Invite"
        ,"Work" : "Work"
        ,"None-Work" : "None-Work"
        ,"Out of Town" : "Out of Town"
        ,"Save" : "Save"
        ,"Cancel" : "Cancel"
        ,"Exit without saving ?" : "Exit without saving ?"
        ,"save failed" : "save failed"
        ,"personal event need not to invite" : "personal event need not to invite"
        ,"Save and Exit without inviting anyone ?" : "Save and Exit without inviting anyone ?"
        ,"hhmma" : "hh:mm a"
        ,"HHmm" : "HH:mm"
        ,"Done" : "Done"
        ,"Title" : "Title"
        ,"Owner" : "Owner"
        ,"Detail" : "Detail"
        ,"Date" : "Date"
        ,"Start Time" : "Start Time"
        ,"End Time" : "End Time"
        ,"Calendar Type" : "Calendar Type"
        ,"Event Type" : "Event Type"
        ,"TimeSensibility" : "TimeSensibility"
        ,"Show Invitation Answer" : "Show Invitation Answer"
        ,"Exit without inviting friend" : "Exit without inviting friend"
        ,"Show Calendar" : "Show Calendar"
        ,"male" : "male"
        ,"female" : "female"
        ,"China" : "China"
        ,"USA" : "USA"
        ,"Canada" : "Canada"
        ,"Others" : "Others"
        ,"username" : "username"
        ,"city" : "city"
        ,"firstName" : "firstName"
        ,"middleName" : "middleName"
        ,"lastName" : "lastName"
        ,"country" : "country"
        ,"phone" : "phone"
        ,"dob" : "dob"
        ,"gender" : "gender"
        ,"email" : "email"
        ,"avatar" : "avatar"
    ]
    
    static let enOtherWords : [String : String] = [
        "free" : "free",
        "Free" : "Free",
        "Do not disturb" : "Do not disturb",
        "Text allowed" : "Text allowed",
        "Call allowed" : "Call allowed",
        ]
    
    static let chnWords : [String : String] = [
        "Calendar" : "日历"
        ,"Back" : "返回"
        ,"Public" : "公共"
        ,"Personal" : "个人"
        ,"Private" : "私人"
        ,"public" : "公共"
        ,"personal" : "个人"
        ,"private" : "私人"
        ,"OK" : "同意"
        ,"Match" : "双匹配"
        ,"Free" : "匹配对方"
        ,"free" : "匹配对方"
        ,"No free time all the day" : "全天无空闲时间"
        ,"not going" : "不参加"
        ,"going" : "参加"
        ,"unread" : "未读"
        ,"undetermined" : "未决定"
        ,"unknown" : "未知"
        ,"get data failed" : "读取数据失败"
        ,"to" : "至"
        ,"Invite" : "邀请"
        ,"Work" : "工作"
        ,"None-Work" : "非工作"
        ,"Out of Town" : "出差"
        ,"Save" : "保存"
        ,"Cancel" : "放弃"
        ,"Exit without saving ?" : "不保存直接退出 ?"
        ,"save failed" : "数据保存失败"
        ,"personal event need not to invite" : "个人事件不需要邀请朋友参加"
        ,"Save and Exit without inviting anyone ?" : "不邀请任何人直接存盘退出 ?"
        ,"hhmma" : "hh:mm a"
        ,"HHmm" : "HH:mm"
        ,"Done" : "完成"
        ,"Title" : "标题"
        ,"Owner" : "所有者"
        ,"Detail" : "详情"
        ,"Date" : "日期"
        ,"Start Time" : "起始时间"
        ,"End Time" : "终止时间"
        ,"Calendar Type" : "日历类型"
        ,"Event Type" : "事件类型"
        ,"TimeSensibility" : "时间局限性"
        ,"Show Invitation Answer" : "查看朋友的应答"
        ,"Exit without inviting friend" : "退出但未邀请好友"
        ,"Show Calendar" : "查看日志"
        ,"male" : "男性"
        ,"female" : "女性"
        ,"China" : "中国"
        ,"USA" : "美国"
        ,"Canada" : "加拿大"
        ,"Others" : "其他国家"
        ,"username" : "用户名称"
        ,"city" : "城市"
        ,"firstName" : "名字"
        ,"middleName" : "中间名字"
        ,"lastName" : "姓氏"
        ,"country" : "国家"
        ,"phone" : "电话号码"
        ,"dob" : "出生日期"
        ,"gender" : "性别"
        ,"email" : "电子邮箱"
        ,"avatar" : "头像"
    ]
    
    static let chnOtherWords : [String : String] = [
        "Free" : "无限制",
        "free" : "无限制",
        "Do not disturb" : "请勿打扰",
        "Text allowed" : "可以收看短信",
        "Call allowed" : "可以接听电话",
        ]
    
    static let keyWords : [String : [String : String]] = ["en" : enWords,"chn" : chnWords]
    
    static let keyOtherWords : [String : [String : String]] = ["en" : enOtherWords,"chn" : chnOtherWords]
    
    static let chnToEnWords : [String : String] = [
        "公共" : "public",
        "个人" : "personal",
        "私人" : "private",
        "不参加" : "not going",
        "参加" : "going",
        "未读" : "unread",
        "未决定" : "undetermined",
        "未知" : "unknown",
        "工作" : "Work",
        "非工作" : "None-Work",
        "出差" :  "Out of Town",
        "匹配对方" : "Free",
        "男性" : "male",
        "女性" : "female",
        "中国" : "China",
        "美国" : "USA",
        "加拿大" : "Canada",
        "其他国家" : "Others",
        ]
    
    static let chnToEnOtherWords : [String : String] = [
        "无限制" : "Free",
        "请勿打扰" : "Do not disturb",
        "可以收看短信" : "Text allowed",
        "可以接听电话" : "Call allowed",
        ]
    
    struct PropertyKey {
        static let Calendar = "Calendar"
        static let Back = "Back"
        static let Public = "Public"
        static let Personal = "Personal"
        static let Private = "Private"
        static let OK = "OK"
        static let Match = "Match"
        static let Free = "Free"
        static let Nofreetimealltheday = "No free time all the day"
        static let notgoing = "not going"
        static let going = "going"
        static let unread = "unread"
        static let undetermined = "undetermined"
        static let unknown = "unknown"
        static let getdatafailed = "get data failed"
        static let to = "to"
        static let Invite = "Invite"
        static let Work = "Work"
        static let NoneWork = "None-Work"
        static let OutofTown = "Out of Town"
        static let Donotdisturb = "Do not disturb"
        static let Textallowed = "Text allowed"
        static let Callallowed = "Call allowed"
        //AM、PM需要转为上午、下午，看看怎么特殊处理
        static let Save = "Save"
        static let Cancel = "Cancel"
        static let Exitwithoutsaving = "Exit without saving ?"
        static let savefailed = "save failed"
        static let SaveandExitwithoutinvitinganyone = "Save and Exit without inviting anyone ?"
        static let hhmma = "hh:mm a"
        static let HHmm = "HH:mm"
        static let Done = "Done"
        static let Title = "Title"
        static let Owner = "Owner"
        static let Detail = "Detail"
        static let Date = "Date"
        static let StartTime = "Start Time"
        static let EndTime = "End Time"
        static let CalendarType = "Calendar Type"
        static let EventType = "Event Type"
        static let TimeSensibility = "TimeSensibility"
        static let ShowInvitationAnswer = "Show Invitation Answer"
        static let Exitwithoutinvitingfriend = "Exit without inviting friend"
        static let ShowCalendar = "Show Calendar"
        static let male = "male"
        static let female = "female"
        static let China = "China"
        static let USA = "USA"
        static let Canada = "Canada"
        static let Others = "Others"
        static let username = "username"
        static let city = "city"
        static let firstName = "firstName"
        static let middleName = "middleName"
        static let lastName = "lastName"
        static let country = "country"
        static let phone = "phone"
        static let dob = "dob"
        static let gender = "gender"
        static let email = "email"
    }
    
    var eCalendar = "Calendar"
    var eBack = "Back"
    var ePublic = "Public"
    var ePersonal = "Personal"
    var ePrivate = "Private"
    var eOK = "OK"
    var eMatch = "Match"
    var eFree = "Free"
    var eNofreetimealltheday = "No free time all the day"
    var enotgoing = "not going"
    var egoing = "going"
    var eunread = "unread"
    var eundetermined = "undetermined"
    var eunknown = "unknown"
    var egetdatafailed = "get data failed"
    var eto = "to"
    var eInvite = "Invite"
    var eWork = "Work"
    var eNoneWork = "None-Work"
    var eOutofTown = "Out of Town"
    var eDonotdisturb = "Do not disturb"
    var eTextallowed = "Text allowed"
    var eCallallowed = "Call allowed"
    var eSave = "Save"
    var eCancel = "Cancel"
    var eExitwithoutsaving = "Exit without saving ?"
    var esavefailed = "save failed"
    var eSaveandExitwithoutinvitinganyone = "Save and Exit without inviting anyone ?"
    var ehhmma = "hh:mm a"
    var eHHmm = "HH:mm"
    var eDone = "Done"
    var eTitle = "Title"
    var eOwner = "Owner"
    var eDetail = "Detail"
    var eDate = "Date"
    var eStartTime = "Start Time"
    var eEndTime = "End Time"
    var eCalendarType = "Calendar Type"
    var eEventType = "Event Type"
    var eTimeSensibility = "TimeSensibility"
    var eShowInvitationAnswer = "Show Invitation Answer"
    var eExitwithoutinvitingfriend = "Exit without inviting friend"
    var eShowCalendar = "Show Calendar"
    var emale = "male"
    var efemale = "female"
    var eChina = "China"
    var eUSA = "USA"
    var eCanada = "Canada"
    var eOthers = "Others"
    var eusername = "username"
    var ecity = "city"
    var efirstName = "firstName"
    var emiddleName = "middleName"
    var elastName = "lastName"
    var ecountry = "country"
    var ephone = "phone"
    var edob = "dob"
    var egender = "gender"
    var eemail = "email"
    
    static let DocumentsDirectory = FileManager().urls(for: .documentDirectory, in: .userDomainMask).first!
    static let ArchiveURL = DocumentsDirectory.appendingPathComponent("StatusParaArr")
    
    //根据语言及关键字返回翻译后的词条
    public static func getWord(keyWord : String)->String {
        //获得手机正在使用的语言
        let languageArr = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
        var languageNow = "en"
        if languageArr.count > 0 {
            languageNow = languageArr[0]
        }
        let keyLanguage = languageNow == "en" ? "en" : "chn"
        var word = EnStatic.keyWords[keyLanguage]![keyWord]
        if word == nil {
            word = keyWord
        }
        return word!
    }
    
    //根据语言及关键字返回翻译后的词条(特殊部分)
    public static func getOtherWord(keyWord : String)->String {
        //获得手机正在使用的语言
        let languageArr = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
        var languageNow = "en"
        if languageArr.count > 0 {
            languageNow = languageArr[0]
        }
        let keyLanguage = languageNow == "en" ? "en" : "chn"
        var word = EnStatic.keyOtherWords[keyLanguage]![keyWord]
        if word == nil {
            word = keyWord
        }
        return word!
    }
    
    //将中文转化为英文
    public static func chnToEnWord(keyWord : String)->String {
        //获得手机正在使用的语言
        let languageArr = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
        var languageNow = "en"
        if languageArr.count > 0 {
            languageNow = languageArr[0]
        }
        let keyLanguage = languageNow == "en" ? "en" : "chn"
        var word = keyWord
        if keyLanguage.compare("chn").rawValue == 0 {
            word = EnStatic.chnToEnWords[keyWord]!
        }
        return word
    }
    
    //将中文转化为英文
    public static func chnToEnOtherWord(keyWord : String)->String {
        //获得手机正在使用的语言
        let languageArr = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
        var languageNow = "en"
        if languageArr.count > 0 {
            languageNow = languageArr[0]
        }
        let keyLanguage = languageNow == "en" ? "en" : "chn"
        var word = keyWord
        if keyLanguage.compare("chn").rawValue == 0 {
            word = EnStatic.chnToEnOtherWords[keyWord]!
        }
        return word
    }
    
    //返回手机正在使用的语言
    public static func languegeUsing()->String {
        //获得手机正在使用的语言
        let languageArr = UserDefaults.standard.object(forKey: "AppleLanguages") as! [String]
        var languageNow = "en"
        if languageArr.count > 0 {
            languageNow = languageArr[0]
        }
        let keyLanguage = languageNow == "en" ? "en" : "chn"
        return keyLanguage
    }
    
    //MARK: Initialization
    
    func encode(with aCoder: NSCoder) {
        aCoder.encode(eCalendar, forKey: PropertyKey.Calendar)
        aCoder.encode(eBack, forKey: PropertyKey.Back)
        aCoder.encode(ePublic, forKey: PropertyKey.Public)
        aCoder.encode(ePersonal, forKey: PropertyKey.Personal)
        aCoder.encode(ePrivate, forKey: PropertyKey.Private)
        aCoder.encode(eOK, forKey: PropertyKey.OK)
        aCoder.encode(eMatch, forKey: PropertyKey.Match)
        aCoder.encode(eFree, forKey: PropertyKey.Free)
        aCoder.encode(eNofreetimealltheday, forKey: PropertyKey.Nofreetimealltheday)
        aCoder.encode(enotgoing, forKey: PropertyKey.notgoing)
        aCoder.encode(egoing, forKey: PropertyKey.going)
        aCoder.encode(eunread, forKey: PropertyKey.unread)
        aCoder.encode(eundetermined, forKey: PropertyKey.undetermined)
        aCoder.encode(eunknown, forKey: PropertyKey.unknown)
        aCoder.encode(egetdatafailed, forKey: PropertyKey.getdatafailed)
        aCoder.encode(eto, forKey: PropertyKey.to)
        aCoder.encode(eInvite, forKey: PropertyKey.Invite)
        aCoder.encode(eWork, forKey: PropertyKey.Work)
        aCoder.encode(eNoneWork, forKey: PropertyKey.NoneWork)
        aCoder.encode(eOutofTown, forKey: PropertyKey.OutofTown)
        aCoder.encode(eDonotdisturb, forKey: PropertyKey.Donotdisturb)
        aCoder.encode(eTextallowed, forKey: PropertyKey.Textallowed)
        aCoder.encode(eCallallowed, forKey: PropertyKey.Callallowed)
        aCoder.encode(eSave, forKey: PropertyKey.Save)
        aCoder.encode(eCancel, forKey: PropertyKey.Cancel)
        aCoder.encode(eExitwithoutsaving, forKey: PropertyKey.Exitwithoutsaving)
        aCoder.encode(esavefailed, forKey: PropertyKey.savefailed)
        aCoder.encode(eSaveandExitwithoutinvitinganyone, forKey: PropertyKey.SaveandExitwithoutinvitinganyone)
        aCoder.encode(ehhmma, forKey: PropertyKey.hhmma)
        aCoder.encode(eHHmm, forKey: PropertyKey.HHmm)
        aCoder.encode(eDone, forKey: PropertyKey.Done)
        aCoder.encode(eTitle, forKey: PropertyKey.Title)
        aCoder.encode(eOwner, forKey: PropertyKey.Owner)
        aCoder.encode(eDetail, forKey: PropertyKey.Detail)
        aCoder.encode(eDate, forKey: PropertyKey.Date)
        aCoder.encode(eStartTime, forKey: PropertyKey.StartTime)
        aCoder.encode(eEndTime, forKey: PropertyKey.EndTime)
        aCoder.encode(eCalendarType, forKey: PropertyKey.CalendarType)
        aCoder.encode(eEventType, forKey: PropertyKey.EventType)
        aCoder.encode(eTimeSensibility, forKey: PropertyKey.TimeSensibility)
        aCoder.encode(eShowInvitationAnswer, forKey: PropertyKey.ShowInvitationAnswer)
        aCoder.encode(eExitwithoutinvitingfriend, forKey: PropertyKey.Exitwithoutinvitingfriend)
        aCoder.encode(eShowCalendar, forKey: PropertyKey.ShowCalendar)
        aCoder.encode(emale, forKey: PropertyKey.male)
        aCoder.encode(efemale, forKey: PropertyKey.female)
        aCoder.encode(eChina, forKey: PropertyKey.China)
        aCoder.encode(eUSA, forKey: PropertyKey.USA)
        aCoder.encode(eCanada, forKey: PropertyKey.Canada)
        aCoder.encode(eOthers, forKey: PropertyKey.Others)
        aCoder.encode(eusername, forKey: PropertyKey.username)
        aCoder.encode(ecity, forKey: PropertyKey.city)
        aCoder.encode(efirstName, forKey: PropertyKey.firstName)
        aCoder.encode(emiddleName, forKey: PropertyKey.middleName)
        aCoder.encode(elastName, forKey: PropertyKey.lastName)
        aCoder.encode(ecountry, forKey: PropertyKey.country)
        aCoder.encode(ephone, forKey: PropertyKey.phone)
        aCoder.encode(edob, forKey: PropertyKey.dob)
        aCoder.encode(egender, forKey: PropertyKey.gender)
        aCoder.encode(eemail, forKey: PropertyKey.email)
    }
    
    required convenience init?(coder aDecoder: NSCoder) {
        // The title is required. If we cannot decode a name string, the initializer should fail.
        guard let vCalendar = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String else {
            os_log("Unable to decode the title for an object.", log: OSLog.default, type: .debug)
            return nil
            
        }
        
        let vBack = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vPublic = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vPersonal = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vPrivate = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vOK = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vMatch = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vFree = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vNofreetimealltheday = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vnotgoing = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vgoing = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vunread = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vundetermined = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vunknown = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vgetdatafailed = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vto = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vInvite = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vWork = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vNoneWork = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vOutofTown = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vDonotdisturb = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vTextallowed = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vCallallowed = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vSave = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vCancel = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vExitwithoutsaving = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vsavefailed = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vSaveandExitwithoutinvitinganyone = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vhhmma = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vHHmm = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vDone = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vTitle = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vOwner = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vDetail = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vDate = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vStartTime = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vEndTime = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vCalendarType = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vEventType = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vTimeSensibility = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vShowInvitationAnswer = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vExitwithoutinvitingfriend = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vShowCalendar = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vmale = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vfemale = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vChina = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vUSA = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vCanada = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vOthers = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vusername = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vcity = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vfirstName = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vmiddleName = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vlastName = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vcountry = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vphone = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vdob = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vgender = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        let vemail = aDecoder.decodeObject(forKey: PropertyKey.Calendar) as? String
        
        // Must call designated initializer.
        self.init(Calendar : vCalendar ,Back : vBack! ,Public : vPublic! ,Personal : vPersonal! ,Private :vPrivate! ,OK : vOK! ,Match : vMatch! ,Free : vFree! ,Nofreetimealltheday : vNofreetimealltheday! ,notgoing : vnotgoing! ,going : vgoing! ,unread : vunread! ,undetermined : vundetermined! ,unknown : vunknown! ,getdatafailed : vgetdatafailed! ,to : vto! ,Invite : vInvite! ,Work : vWork! ,NoneWork : vNoneWork! ,OutofTown : vOutofTown! ,Donotdisturb : vDonotdisturb! ,Textallowed : vTextallowed! ,Callallowed : vCallallowed! ,Save : vSave! ,Cancel : vCancel! ,Exitwithoutsaving : vExitwithoutsaving! ,savefailed : vsavefailed! ,SaveandExitwithoutinvitinganyone : vSaveandExitwithoutinvitinganyone! ,hhmma : vhhmma! ,HHmm : vHHmm! ,Done : vDone! ,Title : vTitle! ,Owner : vOwner! ,Detail : vDetail! ,Date : vDate! ,StartTime : vStartTime! ,EndTime : vEndTime! ,CalendarType : vCalendarType! ,EventType : vEventType! ,TimeSensibility : vTimeSensibility! ,ShowInvitationAnswer : vShowInvitationAnswer! ,Exitwithoutinvitingfriend : vExitwithoutinvitingfriend! ,ShowCalendar : vShowCalendar! ,male : vmale! ,female : vfemale! ,China : vChina! ,USA : vUSA! ,Canada : vCanada! ,Others : vOthers! ,username : vusername! ,city : vcity! ,firstName : vfirstName! ,middleName : vmiddleName! ,lastName : vlastName! ,country : vcountry! ,phone : vphone! ,dob : vdob! ,gender : vgender! ,email : vemail!)
        
    }
    
    init?(Calendar : String, Back : String, Public : String, Personal : String, Private : String, OK : String, Match : String, Free : String, Nofreetimealltheday : String, notgoing : String, going : String, unread : String, undetermined : String, unknown : String, getdatafailed : String, to : String, Invite : String, Work : String, NoneWork : String, OutofTown : String, Donotdisturb : String, Textallowed : String,   Callallowed : String, Save : String, Cancel : String, Exitwithoutsaving : String, savefailed : String, SaveandExitwithoutinvitinganyone : String, hhmma : String, HHmm : String, Done : String, Title : String,          Owner : String, Detail : String, Date : String, StartTime : String, EndTime : String, CalendarType : String, EventType : String, TimeSensibility : String, ShowInvitationAnswer : String, Exitwithoutinvitingfriend : String, ShowCalendar : String , male : String, female : String, China : String, USA : String, Canada : String, Others : String , username : String , city : String , firstName : String  , middleName : String , lastName : String , country : String , phone : String , dob : String , gender : String  , email : String) {
        
        // Initialization should fail if there is no name or if the rating is negative.
        if Calendar.isEmpty  {
            return nil
        }
        
        // Initialize stored properties.
        self.eCalendar = Calendar
        self.eBack = Back
        self.ePublic = Public
        self.ePersonal = Personal
        self.ePrivate = Private
        self.eOK = OK
        self.eMatch = Match
        self.eFree = Free
        self.eNofreetimealltheday = Nofreetimealltheday
        self.enotgoing = notgoing
        self.egoing = going
        self.eunread = unread
        self.eundetermined = undetermined
        self.eunknown = unknown
        self.egetdatafailed = getdatafailed
        self.eto = to
        self.eInvite = Invite
        self.eWork = Work
        self.eNoneWork = NoneWork
        self.eOutofTown = OutofTown
        self.eDonotdisturb = Donotdisturb
        self.eTextallowed = Textallowed
        self.eCallallowed = Callallowed
        self.eSave = Save
        self.eCancel = Cancel
        self.eExitwithoutsaving = Exitwithoutsaving
        self.esavefailed = savefailed
        self.eSaveandExitwithoutinvitinganyone = SaveandExitwithoutinvitinganyone
        self.ehhmma = hhmma
        self.eHHmm = HHmm
        self.eDone = Done
        self.eTitle = Title
        self.eOwner = Owner
        self.eDetail = Detail
        self.eDate = Date
        self.eStartTime = StartTime
        self.eEndTime = EndTime
        self.eCalendarType = CalendarType
        self.eEventType = EventType
        self.eTimeSensibility = TimeSensibility
        self.eShowInvitationAnswer = ShowInvitationAnswer
        self.eExitwithoutinvitingfriend = Exitwithoutinvitingfriend
        self.eShowCalendar = ShowCalendar
        self.emale = male
        self.efemale = female
        self.eChina = China
        self.eUSA = USA
        self.eCanada = Canada
        self.eOthers = Others
        self.eusername = username
        self.ecity = city
        self.efirstName = firstName
        self.emiddleName = middleName
        self.elastName = lastName
        self.ecountry = country
        self.ephone = phone
        self.edob = dob
        self.egender = gender
        self.eemail = email
        
    }
    
}
